using System;
using DevExpress.ExpressApp.DC;
using DevExpress.Persistent.Base;

namespace AppSolution.Module
{
    [DomainComponent]
    [DefaultClassOptions]
    public interface InterFaceData
    {
        string PersistentProperty { get; set; }
        string CalculatedProperty { get; }
        string moh { get; set; }
        string SumMethod(int val1, int val2);
    }
    [DomainLogic(typeof(InterFaceData))]
    public class InterFaceDataLogic
    {
        public static string Get_CalculatedProperty(InterFaceData instance)
        {
            // A "Get_" method is executed when getting the target member value. The target member should be readonly. 
            // You can use this method to implement calculated properties.

            return instance.PersistentProperty + "ok";
        }
        public static string Init_PersistentProperty(InterFaceData instance)
        {
            // An "Init_" method is executed when the target member is initialized. The target member should not be readonly. 
            // You can use this method to specify a property's initial value.
            return "abc";
        }
        public static void AfterChange_PersistentProperty(InterFaceData instance)
        {
            // An "AfterChange_" method is executed after the target member is changed. The target member should not be readonly. 
            // You can use this method to implement dependant properties.
            instance.moh += "1";
            instance.moh = SumMethod(instance, 2, 5);
        }
        public static void AfterConstruction(InterFaceData instance)
        {
            // The "AfterConstruction" method is executed after an object is constructed. 
            // You can use this method instead of the previous one, to initialize several properties at once.
        }
        public static string SumMethod(InterFaceData instance, int val1, int val2)
        {
            // You can define additional methods which can be called from methods implementing the Domain Logic.
            return instance.CalculatedProperty + Convert.ToString(val1 + val2);
            //return val1 + val2;
        }
    }
}
